package cloud.daodao.storm.user.controller;

import cloud.daodao.storm.common.model.PageData;
import cloud.daodao.storm.common.model.PageParam;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import cloud.daodao.storm.common.user.api.RoleApi;
import cloud.daodao.storm.common.user.model.role.RoleData;
import cloud.daodao.storm.common.user.model.role.RoleSearch;
import cloud.daodao.storm.common.user.model.role.RoleSelect;
import cloud.daodao.storm.common.user.model.role.RoleUpsert;
import cloud.daodao.storm.user.service.RoleService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DaoDao
 */
@RestController
public class RoleController implements RoleApi {

    @Resource
    private RoleService roleService;

    @Override
    public Response<RoleData> roleSelect(Request<RoleSelect> request) {
        RoleData data = roleService.roleSelect(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<RoleData> roleUpsert(Request<RoleUpsert> request) {
        RoleData data = roleService.roleUpsert(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<PageData<RoleData>> roleSearch(Request<PageParam<RoleSearch>> request) {
        PageData<RoleData> data = roleService.roleSearch(request.getParam());
        return new Response<>(data);
    }

}
